package routers

import (
	"github.com/gin-gonic/gin"
	"itachi/middleware/jwt"
	"itachi/routers/api"
	"itachi/routers/api/v1"
)

func InitRouter() *gin.Engine {
	engine := gin.New()
	engine.Use(gin.Logger())
	engine.Use(gin.Recovery())

	engine.GET("/auth", api.GetAuth)

	group := engine.Group("/api/v1")
	group.Use(jwt.JWT())
	{
		group.GET("/tags", v1.GetTags)
		group.POST("/tags", v1.AddTag)
		group.PUT("/tags/:id", v1.EditTag)
		group.DELETE("/tags/:id", v1.DeleteTag)
	}

	{
		group.GET("/articles", v1.GetArticles)
		group.GET("/article/:id", v1.GetArticle)
		group.POST("/articles", v1.AddArticle)
		group.PUT("/articles/:id", v1.EditArticle)
		group.DELETE("/articles/:id", v1.DeleteArticle)
	}

	return engine

}
